package com.nulldev.util.web.HttpServer3;

import com.nulldev.util.JVM.Arguments;
import com.nulldev.util.manage.experiments.Experiments;

public class HttpServer3Flags {
	/**
	 * HttpServer3: Flag <br>
	 * Experimental: <b>TRUE</b><br>
	 * Enabled by default: FALSE <br>
	 * Enables partial reading for InputStreams.
	 */
	public boolean requests_enable_byte_ranges = false;
	/**
	 * HttpServer3: Flag <br>
	 * Experimental: <b>FALSE</b><br>
	 * Enabled by default: TRUE <br>
	 * Enables the GZIP compressor as a content encoding.
	 */
	public boolean responses_enable_gzip_encoding = true;
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>FALSE</b><br>
	 * Disabled by default. <br>
	 * Attempts to keep connections alive over TCP.
	 */
	public boolean tcp_keep_alive = Arguments.hasArgument("--HttpServer3.enableTCPKeepAlive");
//	/**
//	 * HttpServer3: Flag<br>
//	 * Experimental: <b>TRUE</b><br>
//	 * Enabled by default. <br>
//	 * Requires a HTTP/1.1 request. <br>
//	 * Attempts to reduce connections required by maintaining a single connection.
//	 * <br>
//	 * Optional Requirement: enable_chunked_transfers
//	 */
//	public  boolean prefer_constant_connections = Arguments.notArguments("--HttpServer3.disableConstantConnection");
	/**
	 * HttpServer3: Flag<br>
	 * Disabled TCP No Delay. (RFC 896) <br>
	 * Enabled by default.
	 */
	public boolean force_disable_nodelay = Experiments.get("http-server://disable-no-delay/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enables Transfer-Encoding: chunked.
	 */
	public boolean enable_chunked_transfers = Arguments.hasArgument("--HttpServer3.enableChunking");
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Allows compression to be used for chunked transfers.
	 */
	public boolean enable_compressed_chunked_transfers = Arguments.hasArgument("--HttpServer3.enableCompressedChunking");
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Converts the HttpPage1 API to 2.0 via <code>HttpPage2.convert</code> instead
	 * of allowing it to coexist. <br>
	 * <b>Applies to HttpPage 1.0 only.</b>
	 */
	public boolean use_convert_function = Arguments.hasArgument("--HttpServer3.useConvertFunction");
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enabled by default. <br>
	 * Uses a multi-threaded GZIP compressor over a single thread bound one. <br>
	 * WARNING: The global executor and parallel GZIP don't scale well!
	 */
	public boolean use_parallel_gzip = Experiments.get("http-server://parallel-gzip/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * This option takes priority over 'use_parallel_gzip'. <br>
	 * Disabled by default. <br>
	 * Uses a multi-threaded GZIP compressor over a single thread bound one. <br>
	 * <b>WARNING</b>: MIGz is not fully compliant with GZIP!
	 */
	public boolean use_migz_for_gzip = Experiments.get("http-server://migz-for-gzip/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Disabled by default as this can break things. <br>
	 * Uses a dedicated task to perform requests and responses. <br>
	 * This also allows for the use of X-Request-Time-Limit. <br>
	 * Blocked by:
	 * <ul>
	 * <li>NTUBE_BUG: rxPlayer fails with option enabled</li>
	 * <li>GENERAL_STABILITY_TEST (partial PASS as of nullUtil 3.0.1)</li>
	 * <li>BQDE_DOS_QUEUE_MANAGEMENT</li>
	 * </ul>
	 */
	public boolean enable_queued_requests = Experiments.get("http-server://queued-requests/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Tells the socket to prefer high throughput over latency and connection time.
	 */
	public boolean sockets_set_throughput = Experiments.get("http-server://throughput-preference/").isActive();

	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Status: <b>Implemented but requires more tweaking.</b><br>
	 * Enables the HTTP2 protocol.
	 */
	public boolean enable_http2 = false;

	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Status: <b>COMPLETE</b><br>
	 * Enables the Server-Sent Events protocol.
	 */
	public boolean enable_sse = Experiments.get("http-server://enable-sse/").isActive();

	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Status: <b>COMPLETE</b><br>
	 * Enables the WebSocket protocol.
	 */
	public boolean enable_ws = Experiments.get("http-server://enable-ws/").isActive();

	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enabled by default. <br>
	 * Uses EMAPI's asyncSubmission() over submit() for more smoother client
	 * handling and balancing.
	 */
	public boolean use_async_submissions = Experiments.get("http-server://use-async-submit/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Uses a TrieMap over the FastHashMap for page access and storage.
	 */
	public boolean use_trie_map = Experiments.get("http-server://use-trie-map/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enabled by default. <br>
	 * Sends a `Permissions-Policy` header to disable FLoC. <br>
	 * TODO: Either remove this option or limit it to >=Chrome 97
	 */
	public boolean opt_out_floc = Experiments.get("http-server://opt-out-floc/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enables the use of HTTP status code 103 (RFC 8297) to send preload hints.
	 * <br>
	 * <b>WARNING: This feature may break older browsers which treat the status code
	 * as the response.</b>
	 */
	public boolean enable_early_hints = Experiments.get("http-server://early-hints/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Enable to rollback changes that were intended to improve performance,
	 * re-enables flushing after the header is sent. <br>
	 * Disabled by default.
	 */
	public boolean post_response_header_flushing = Experiments.get("http-server://post-response-header-flushing/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Reduces the amount of flush() calls that are invoked during the response
	 * process. <br>
	 * <b>WARNING: This feature may break HTTP compliance and cause issues!</b>
	 */
	public boolean reduce_response_flushing = Experiments.get("http-server://response-reduce-flushing/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Enables larger input and output buffers, allowing for window scaling to take
	 * place. <br>
	 * Disabled by default.
	 */
	public boolean use_dynamic_buffer_sizes = Experiments.get("http-server://dynamic-buffer-sizes/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Re-enables the old but now improved guessing logic for generating a
	 * Content-Length header. <br>
	 * Disabled by default.
	 */
	public boolean response_guess_content_length = Experiments.get("http-server://response-guess-content-length/").isActive();
	/**
	 * HttpServer3: Flag<br>
	 * Experimental: <b>TRUE</b><br>
	 * Attempts to half-close the socket early when possible. <br>
	 * Only supported on HTTP connections. <br>
	 * Disabled by default.
	 */
	public boolean enable_early_socket_close = Experiments.get("http-server://enable-early-socket-close/").isActive();
}
